/**
 * 
 */
package com.yishuki.bluewhale.db.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.yishuki.bluewhale.Constant;

/**
 * @author yhzhu
 *
 */
@Entity
@Table(name="TBL_PRODUCTION_IMAGE")
public class ProductionImage implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name="IMAGE_ID")
	private Long imageId;
	
	@Column(name="IMAGE")
	private byte[] image;

	@Column(name="ORDERED")
	private Integer order ;

	@Column(name="PRODUCTION_ID")
	private Long productionId;
	
	public Long getImageId() {
		return imageId;
	}

	public void setImageId(Long imageId) {
		this.imageId = imageId;
	}

	public Integer getOrder() {
		return order;
	}

	/**
	 * the image order in the production .
	 * the minimum order image should be loaded when a production is display
	 * @param order the minimum value is 0, the maximum is {@link Constant.MAX_NUMBER_OF_PRODCTION_IMAGE}
	 */
	public void setOrder(Integer order) {
		if (order >=0 && order <Constant.MAX_NUMBER_OF_PRODCTION_IMAGE)
		    this.order = order;
		else 
			throw new IllegalArgumentException(" the order range is between 0 to "+
					Constant.MAX_NUMBER_OF_PRODCTION_IMAGE);
	}

	public byte[] getImage() {
		return image;
	}

	public void setImage(byte[] image) {
		this.image = image;
	}

	public Long getProductionId() {
		return productionId;
	}

	public void setProductionId(Long productionId) {
		this.productionId = productionId;
	}
	
}
